<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Knowledges extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('knowledges', ['id'=>'id', 'comment'=>'专家指导', 'engine'=>'innodb']);

        $table->addColumn('title', 'string', ['comment'=>'标题'])
              ->addColumn('content', 'text', ['comment'=>'内容'])
              ->addColumn('images', 'text', ['null'=>true, 'comment'=>'辅助图片'])
              ->addColumn('publisher', 'integer', ['length'=>10, 'comment'=>'发布者id'])
              ->addColumn('push_type', 'string', ['comment'=>'推送类型 right_away:立即推送, reserve:预约推送', 'default'=>'right_away'])
              ->addColumn('reserve_time', 'datetime', ['comment'=>'预约推送时间', 'null'=>true])
              ->addColumn('push_state', 'integer', ['length'=>5, 'comment'=>'推送状态, 0:待推送, 1:已推送, 2:撤销推送, 3:撤回推送', 'default'=>0])
              ->addTimestamps()
              ->create();
    }
}
